netfilter: nf_tables: fix memleak when more than 255 elements expired
authorSasha Levin <sashal@kernel.org>
Fri, 22 Sep 2023 17:01:18 +0000 (19:01 +0200)
committerSalvatore Bonaccorso <carnil@debian.org>
Fri, 29 Sep 2023 04:25:15 +0000 (05:25 +0100)
commitc3f854ee8717d0c3ec08dcd63a410bc44ac0b977
tree316729761cbdbaca3c0d9691d82518263286019d
parent56379b76caf739b9c3f3fc7cda46e605452fa359
netfilter: nf_tables: fix memleak when more than 255 elements expired

commit cf5000a7787cbc10341091d37245a42c119d26c5 upstream.

When more than 255 elements expired we're supposed to switch to a new gc
container structure.

This never happens: u8 type will wrap before reaching the boundary
and nft_trans_gc_space() always returns true.

This means we recycle the initial gc container structure and
lose track of the elements that came before.

While at it, don't deref 'gc' after we've passed it to call_rcu.

Fixes: 5f68718b34a5 ("netfilter: nf_tables: GC transaction API to avoid race with control plane")
Reported-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Gbp-Pq: Topic bugfix/all
Gbp-Pq: Name netfilter-nf_tables-fix-memleak-when-more-than-255-e.patch
include/net/netfilter/nf_tables.h
net/netfilter/nf_tables_api.c